<template>
	<div>
		<el-popover placement="bottom" trigger="hover">
			<div class="popover-content">
				<span class="popover-content-title" @click="loadDetails">详情</span>
				<span class="popover-content-title" @click="loadRename">修改</span>
				<span class="popover-content-title" @click="loadDel">删除</span>
			</div>
			<i slot="reference" class="document-left-tree-more el-icon-more"></i>
		</el-popover>
		<fileEdit ref='fileEdit' :treeData="treeData"></fileEdit>
		<details-content ref="details" :treeData="treeData"></details-content>
		<del-content ref='del' :treeData="treeData"></del-content>
	</div>

</template>

<script>
	import fileEdit from '../../document/components/fileEdit'
	import delContent from '../../document/components/del.vue'
	import detailsContent from '../../document/components/details.vue'
	import {del} from '@/api/doc.js'
	export default {
		data() {
			return {

			}
		},
		components: {
			fileEdit,
			delContent,
			detailsContent,
		},
		props: ['treeData',],
		methods: {
			loadTopping() {
				this.$message({
					showClose: true,
					message: '置顶成功',
					type: 'success'
				});
			},
			loadRename() {
				if (this.treeData.docType == '04' || this.treeData.docType == '05') {
					var data = {
						docType: this.treeData.docType,
						dirId: this.treeData.dirId,
						docId:this.treeData.docId
					}
					this.$router.push({
						path: '/document/edit',
						query: {
							data: JSON.stringify(data)
						}
					})
				} else {
					this.$refs.fileEdit.loadFileEdit()
				}
			},
			loadDel() {
				this.$refs.del.loadDel('file')
			},
			loadDetails() {
				// this.$refs.details.loadDetails()
				var data = {
						docType: this.treeData.docType,
						dirId: this.treeData.dirId,
						docId:this.treeData.docId
					}
					if(this.documentType == '合同'){
						this.$router.push({
							path: '/contract/details',
							query: {
								data: JSON.stringify(data)
							}
						})
					}else{
						this.$router.push({
							path: '/document/details',
							query: {
								data: JSON.stringify(data)
							}
						})
					
						// this.$refs.fileEdit.loadFileEdit()
						// if(this.treeData.docType=='02'&&this.treeData.docSubtype=='04'){
						// 		this.$refs.details.loadDetails()
						// }else{
						// 	this.$router.push({
						// 	path: '/document/details',
						// 	query: {
						// 		data: JSON.stringify(data)
						// 	}
						// })
						// }
					}

			},
			// 更新文档
			updateDocList(data, type) {
				var docForm = {
					data: data,
					type: type
				}
				this.$EventBus.$emit('updateDoc', docForm)
			},
			// 彻底删除
			thoroughFile() {
				var _this = this
				this.$confirm('此操作将永久删除该文件, 是否继续?', '彻底删除', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					del({
						ids: this.treeData.docId
					}).then(res => {
						console.log(res)
						_this.updateDocList(this.treeData, 'del')
						_this.$message({
							showClose: true,
							message: '删除成功',
							type: 'success'
						});
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			// 恢复至
			recoveryFile() {
				var _this = this
				var data = {
					data: {
						dirId: _this.treeData.dirId,
						dirType: _this.treeData.docType,
						docId: _this.treeData.docId
					}
				}
				this.$refs.recovery.loadRecovery(data)
			}
		}
	}
</script>

<style scoped>
	.document-left-tree-more {
		font-size: 12px;
	}
	.popover-content-title {
		color: #2e405e;
		font-size: 14px;
		display: block;
		width: 100%;
		padding-top: 10px;
		padding-bottom: 10px;
		padding-left: 10px;
		padding-right: 10px;
		text-align: center;
		
	}

	.popover-content-title:hover {
		background-color: #f5f6f8;
	}

	/deep/.el-popover {
		padding: 0;
	}
</style>
